

// 注册H5端播放视频代理, 供 preload.js 调用
window.api?.setH5VideoPlayImpl( (option)=>{
  console.log('[videoPlayImpl] initH5VideoPlayImpl', JSON.stringify(option))
  if (option.type === 'play') {
    return _playVideo(option.param.name, option.param.isLoop, option.param.callback) 
    
  } else if (option.type === 'stop') {
    return _stopVideo()
    
  } 
})

// 接收H5页面视频播放结果 
uni.$on('Evt_PlayVideoRsp', _onPlayResult)

var playCallback = null 
var timerId = null 


function _onPlayResult(isSucc) {
  console.log('[videoPlayImpl] 00000 _onPlayResult: ', isSucc) 
  if (playCallback) {
    if (isSucc) {
      playCallback({code:200, message: '成功'})
    } else {
      playCallback({code:400, message: '失败'})
    } 
  }
}

function _playVideo(name, isLoop, callback) {
  playCallback = callback 
  uni.$emit('Evt_PlayVideo', {name, isLoop}) 
}

function _stopVideo() {
  
}



